<?php
class Manageaccount_Data_Updatedata {
	
	private $secure;
	private $database;
	
	public function __construct(){
		$this->secure = new Core_Data_Secure();
		$this->database = new Core_Driver_MysqlImproved();
	}
	
	public function update(array $postVars, $username){
		$postVars = $this->secure->parseData($postVars);
		$username = $postVars['username'];
		$realname = $postVars['realname'];
		$email = $postVars['email'];
		$password = $postVars['password'];
		$updateAccount = $postVars['updateAccount'];
		$language = $postVars['language'];
		
		$this->database->connect();
		$updateAccount = $this->database->escape($updateAccount);
		$username = $this->database->escape($username);
		$realname = $this->database->escape($realname);
		$email = $this->database->escape($email);
		$password = $this->database->escape($password);
		$language = $this->database->escape($language);
		$this->database->prepare(
			"
				UPDATE users SET users_language = '$language', users_username = '$username', users_realname = '$realname', users_email = '$email', users_password = '$password' WHERE users_username = '$updateAccount';
				"
		);
		$this->database->query();
		$this->database->dataOperations();
		$content = "<strong>".MANAGE_ACCOUNT_NEW_DATA_MESSAGE."</strong><br>";
		$content .= MANAGE_ACCOUNT_NEW_DATA_LANGUAGE_MESSAGE."$language<br>";
		$content .= MANAGE_ACCOUNT_NEW_DATA_USERNAME_MESSAGE."$username<br>";
		$content .= MANAGE_ACCOUNT_NEW_DATA_PASSWORD_MESSAGE."$password<br>";
		$content .= MANAGE_ACCOUNT_NEW_DATA_REALNAME_MESSAGE."$realname<br>";
		$content .= MANAGE_ACCOUNT_NEW_DATA_EMAIL_MESSAGE."$email<br>";
		$content .= MANAGE_ACCOUNT_NEW_DATA_USE_MESSAGE."<br>";
		return $content;
	}
}